package com.jd.sunny.java;

/**
 * @Description:
 * @author:sunlin
 * @since:2012-12-04 16:38
 * @version:1.0.0
 */
public class TestStaticInnerClass {

    public static void main(String[] args) {
        double []values = {1,2,3,4,5};
        Pair pair =  minmax(values);
        System.out.println("min=" + pair.getMin() + " max=" + pair.getMax());
    }

    public static Pair minmax(double []values){
        double min = Double.MAX_VALUE;
        double max = Double.MIN_VALUE;
        for (double d:values){
            if(min>d){
                min = d;
            }
            if(max<d){
                max = d;
            }
        }
        Pair pair = new Pair(min,max);
        return pair;
    }
    /**
     * static inner class
     * we don't need to access outer class ,so wo can use static to modify the inner  class
     */
    public static class Pair{

        private double min;
        private double  max;

        public Pair(double min, double max) {
            this.min = min;
            this.max = max;
        }

        public double getMin() {
            return min;
        }

        public void setMin(double min) {
            this.min = min;
        }

        public double getMax() {
            return max;
        }

        public void setMax(double max) {
            this.max = max;
        }
    }

}
